import type {TableHeader} from "~/resource/types/common/tableHeader";

export const useProperty = (table: object, tableHeader: TableHeader): string => {
    if (!table.hasOwnProperty(tableHeader.key)) {
        return null;
    }
    const propertyObj = table[tableHeader.key];
    if (!tableHeader.subKey) {
        return propertyObj;
    }
    if (!propertyObj.hasOwnProperty(tableHeader.subKey)) {
        return propertyObj;
    }
    return propertyObj[tableHeader.subKey];
}

export const useLanguageProperty = (tableHeader: TableHeader): string => {
    return "table.header." + tableHeader.category + "." + tableHeader.key;
}